package net.markos.entities;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "ENTITY_B")
public class EntityB {

	private Long id;
	private String name;
	private EntityA entityA;
	private List<EntityC> cList;

	@Id
	@Column(name = "ID", unique = true, nullable = false, precision = 12, scale = 0)
	@GeneratedValue
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Column(name = "NAME")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "entityB", targetEntity=EntityC.class)
	public List<EntityC> getCList() {
		return cList;
	}

	public void setCList(List<EntityC> list) {
		cList = list;
	}
	
	@ManyToOne(fetch = FetchType.LAZY, cascade=CascadeType.ALL)
	@JoinColumn(name = "ENTITY_A_ID", nullable = false, updatable = false, insertable = false, referencedColumnName="id")
	public EntityA getEntityA() {
		return entityA;
	}

	public void setEntityA(EntityA entityA) {
		this.entityA = entityA;
	}

}
